var dataUtil = {
  /**
   * 检查数据是否合法，合法则返回true
   *   type="text" 文本
   *   type="integer" 正整数
   *   type="number" 正数
   *   type="integerAll" 整数
   *   type="numberAll" 数字
   *   type="phone" 电话
   *   type="carNumber" 车牌
   *   type="idCard" 身份证
   *   type="email" 邮箱
   *   type="http" 网址
   *   type="https" 网址
   */
  checkData: (data, type) => engineData.checkData(data, type),

  /**
   * 验证数据是否合法，返回result.success、result.data
   */
  verifyData: (data, type) => engineData.verifyData(data, type),

  /**
   * 格式化数据，时间单位为秒
   *   type="time", option="yyyy年MM月dd日HH小时mm分钟ss秒" // 时间，string类型，失败返回""
   *   type="timeLen", option="dd天HH小时mm分钟ss秒" // 时间差，string类型，失败返回""
   *   type="timeNumber" // 时间戳，number类型，失败返回0
   *   type="date", option不传则为"none", option="start"（00:00:00）, option="end"（23:59:59） // 日期，Date类型，失败返回null
   *   type="price" option不传则为2 // 四舍五入的价格 精确到小数点的位数，number类型，失败返回0
   *   type="floorPrice" option不传则为2 // 四舍不五入的价格 精确到小数点的位数，number类型，失败返回0
   *   type="chinesePrice" option不传则为"simple", option="tradition" // 汉字的价格，string类型，失败返回""
   */
  formatData: (data, type, option) => engineData.formatData(data, type, option),

  /**
   * 获取Url后缀的对象
   */
  getUrlSuffixObj: (url) => engineData.getUrlSuffixObj(url),

  /**
   * 获取Html的Style的对象
   */
  getHtmlStyleObj: (style) => engineData.getHtmlStyleObj(style),

  /**
   * 获取格式化的数组
   *   keyCallback: function(key: string, value?: any): string; 返回格式化的key
   *   valueCallback: function(value: any, key?: string): any; 返回格式化的value
   */
  getArrayByFormat: (array, keyCallback, valueCallback) => engineData.getArrayByFormat(array, keyCallback, valueCallback),

  /**
   * 获取元素不重复的数组
   */
  getArrayByNoRepeat: (array) => engineData.getArrayByNoRepeat(array)
};

export default {
  /**
   * 业务指令的处理对象
   */
  request: null,

  /**
   * 资源指令的处理对象
   */
  demand: null,

  /**
   * 数据转换的处理对象
   */
  dataUtil: dataUtil,

  /**
   * 全局缓存的处理对象
   */
  getApp: () => engine.getApp(),

  /**
   * 创建输入组件、选择组件、对话框组件的数据操作对象
   *   constructor(obj?: any); obj不为空则添加obj所有属性
   *   setData(obj: any): void; 添加obj所有属性到当前对象中
   *   getData(): object; 获取所有已添加的属性的对象
   *   clearData(): void; 移除所有已添加的属性
   *   checkData(key?: string): boolean; 检查已添加属性的数据是否合法，不为空则检查对应属性的数据，为空则检查所有属性的数据
   *   setDialogVisible(visible: boolean): void; 设置对话框是否可见
   *   isDialogVisible(): boolean; 获取对话框显示状态
   */
  createInputObj: (id, obj) => engine.createInputObj(id, obj),

  /**
   * 不创建，只获取输入组件、选择组件、对话框组件的数据操作对象
   */
  getInputObj: (id) => engine.getInputObj(id),

  /**
   * 创建分页取数据的操作对象
   *   constructor(page, pageSize);
   *   getUrl(isFromUp, isShowLoading, url, param, withoutAccount, linkId): Promise; data.pageList为显示的数据
   *   postUrl(isFromUp, isShowLoading, url, param, withoutAccount, linkId): Promise; 
   *   deleteUrl(isFromUp, isShowLoading, url, param, withoutAccount, linkId): Promise; 
   *   putUrl(isFromUp, isShowLoading, url, param, withoutAccount, linkId): Promise;
   */
  createTablePageObj: (page, pageSize) => engine.createTablePageObj(page, pageSize),

  /**
   * 打印日志，对外版本会进行隐藏
   */
  log: (tag, msg) => engine.log(tag, msg),

  /**
   * 是否为开发版本，返回true则为开发版本
   */
  isDebugMode: () => engine.isDebugMode(),

  /**
   * 获取当前运行的平台，返回"wx"
   */
  getCurrentPlatform: () => engine.getCurrentPlatform(),

  /**
   * 获取应用的配置
   */
  getAppConfig: () => engine.getAppConfig(),

  /**
   * 显示提示框
   */
  toast: (msg) => engine.toast(msg),

  /**
   * 显示加载框，需手动调用hideLoading进行隐藏
   */
  showLoading: (msg) => engine.showLoading(msg),

  /**
   * 隐藏加载框
   */
  hideLoading: () => engine.hideLoading(),

  /**
   * 显示提示对话框
   *   param.title?: string;
   *   param.content?: string;
   *   param.showCancel?: boolean; 不传则为true
   *   param.cancelText?: string; 不传则为取消
   *   param.confirmText?: string; 不传则为确定
   *   callback: function(success: boolean, result: null | string): void
   */
  showModal: (param, callback) => engine.showModal(param, callback),

  /**
   * 显示选择对话框
   *   param.itemList 字符串数组
   *   callback: function(success: boolean, result: number | string): void
   */
  showActionSheet: (param, callback) => engine.showActionSheet(param, callback),

  /**
   * 显示授权对话框
   *   scope: scope.userInfo、scope.userLocation、scope.camera、scope.record、scope.writePhotosAlbum、scope.address、scope.werun
   *   callback: function(success: boolean, result: null | string): void
   */
  showScopeWarn: (scope, callback) => engine.showScopeWarn(scope, callback),

  /**
   * 相对像素转成像素，返回像素px
   */
  rpx2px: (rpxValue) => engine.rpx2px(rpxValue),

  /**
   * 像素转成相对像素，返回相对像素rpx
   */
  px2rpx: (pxValue) => engine.px2rpx(pxValue),

  /**
   * 获取窗口的宽度，返回像素px
   */
  getWindowWidth: () => engine.getWindowWidth(),

  /**
   * 获取窗口的高度，返回像素px
   */
  getWindowHeight: () => engine.getWindowHeight(),

  /**
   * 获取窗口的相对高度，返回相对像素rpx
   */
  getWindowRelativeHeight: () => engine.getWindowRelativeHeight(),

  /**
   * 创建动画实例,返回Animation
   *   param.duration 动画持续时间
   *   param.delay 动画延迟时间
   *   param.timingFunction 不传则为"linear"
   */
  createAnimation: (param) => engine.createAnimation(param),

  /**
   * 设置当前页面的标题
   */
  setPageTitle: (title) => engine.setPageTitle(title),

  /**
   * 停止下拉刷新
   */
  stopPullDownRefresh: () => engine.stopPullDownRefresh(),

  /**
   * 设置剪贴板的内容
   *   text: string
   *   callback: function(success: boolean, result: null | string): void
   */
  setClipboardData: (text, callback) => engine.setClipboardData(text, callback),

  /**
   * 获取剪贴板的内容
   *   callback: function(success: boolean, result: string | null): void
   */
  getClipboardData: (callback) => engine.getClipboardData(callback),

  /**
   * 关闭页面
   *   backPageNum: number; 不传则返回上一页
   */
  finishPage: (backPageNum) => engine.finishPage(backPageNum),

  /**
   * 跳转到其他小程序页面
   */
  jumpMiniAppPage: (appId, isRelease, dest, param, isFinish) => engine.jumpMiniAppPage(appId, isRelease, dest, param, isFinish),

  /**
   * 跳转到下一个页面
   */
  jumpPage: (dest, param, isFinish) => engine.jumpPage(dest, param, isFinish),

  /**
   * 跳转到首页
   */
  jumpHomePage: (dest) => engine.jumpHomePage(dest),

  /**
   * 获取上一个页面的对象
   */
  getPrevPage: () => engine.getPrevPage(),

  /**
   * 根据key获取本地数据
   */
  getAccountCache: (key) => engine.getAccountCache(key),

  /**
   * 设置本地数据，相同key则覆盖数据，value传undefined或null则移除对应的数据
   */
  setAccountCache: (key, value) => engine.setAccountCache(key, value),

  /**
   * 清除本地数据
   */
  clearAccountCache: () => engine.clearAccountCache(),

  /**
   * 发起get请求
   */
  getUrl: (isShowLoading, url, param, withoutAccount, linkId) => engine.getUrl(isShowLoading, url, param, withoutAccount, linkId),

  /**
   * 发起post请求
   */
  postUrl: (isShowLoading, url, param, withoutAccount, linkId) => engine.postUrl(isShowLoading, url, param, withoutAccount, linkId),

  /**
   * 发起delete请求
   */
  deleteUrl: (isShowLoading, url, param, withoutAccount, linkId) => engine.deleteUrl(isShowLoading, url, param, withoutAccount, linkId),

  /**
   * 发起put请求
   */
  putUrl: (isShowLoading, url, param, withoutAccount, linkId) => engine.putUrl(isShowLoading, url, param, withoutAccount, linkId),

  /**
   * 发起上传文件请求
   */
  uploadFile: (isShowLoading, url, fileName, filePath, formData) => engine.uploadFile(isShowLoading, url, fileName, filePath, formData),

  /**
   * 发起下载文件请求
   */
  downloadFile: (url, callback) => engine.downloadFile(url, callback),

  /**
   * 获取当前位置
   *   param.type: number; 0只取经纬度，1取经纬度和省市区，2取经纬度、省市区和详细地址，不传则type=1
   *   callback: function(success: boolean, result: any): void
   *     succes==true type>=0 返回result.latitude、result.longitude
   *     succes==true type>=1 返回result.province、result.city、result.district
   *     succes==true type==2 返回result.address
   *     succes==false string类型的错误信息
   */
  getLocation: (isShowLoading, param, callback) => engine.getLocation(isShowLoading, param, callback),

  /**
   * 查看地图上的位置
   *   param.latitude
   *   param.longitude
   *   param.scale
   *   param.name
   *   param.address
   */
  openLocation: (param) => engine.openLocation(param),

  /**
   * 查看全屏的图片
   *   param.urls 图片路径的字符串数组
   *   param.current?: string | number 图片路径或者数组的索引
   */
  previewImage: (param) => engine.previewImage(param),

  /**
   * 选择本地相册的图片或使用相机拍照
   *   param.count: number; 最大可选的图片数量，不传则为1
   *   param.sourceType 不传则为["album", "camera"]
   *   param.sizeType 不传则为["original", "compressed"]
   *   callback: function(success: boolean, result: array | string): void
   */
  chooseImage: (param, callback) => engine.chooseImage(param, callback),

  /**
   * 保存图片到系统相册
   *   path: string
   *   callback: function(success: boolean, result: null | string): void
   */
  saveImage: (path, callback) => engine.saveImage(path, callback),

  /**
   * 获取我的code和token
   *   callback: function(result: IAccount | null): void; 成功则返回result.code、result.token
   */
  getAccount: (callback) => engine.getAccount(callback),

  /**
   * 获取我的session
   * callback: function(result: IAccount | null): void; 成功则返回result.session
   */
  getAccountSession: (isShowLoading, callback) => engine.getAccountSession(isShowLoading, callback),

  /**
   * 获取我的code，只返回本地数据
   */
  getAccountCodeSync: () => engine.getAccountCodeSync(),

  /**
   * 获取我的session，只返回本地数据
   */
  getAccountSessionSync: () => engine.getAccountSessionSync(),

  /**
   * 获取我的名字，只返回本地数据
   */
  getMyNameSync: () => engine.getMyNameSync(),

  /**
   * 获取我的头像，只返回本地数据
   */
  getMyIconSync: () => engine.getMyIconSync(),

  /**
   * 获取我的手机号，只返回本地数据
   */
  getMyPhoneSync: () => engine.getMyPhoneSync(),

  /**
   * 保存用户数据
   */
  saveAccount: data => engine.saveAccount(data),

  /**
   * 获取解密数据
   */
  getDecryptData: (isShowLoading, url, param, callback, isTryAgain) => engine.getDecryptData(isShowLoading, url, param, callback, isTryAgain),

  /**
   * 获取运动步数
   */
  getRunData: (isShowLoading, callback) => engine.getRunData(isShowLoading, callback),

    /**
   * 上传运动步数
   */
  uploadStep: () => engine.uploadStep(),

  /**
   * 发起支付
   */
  requestPayment: (param, callback) => engine.requestPayment(param, callback),

  /**
   * 拨打电话
   */
  makePhoneCall: (phoneNumber) => engine.makePhoneCall(phoneNumber),

  /**
   * 扫描二维码
   *   param.onlyFromCamera: boolean; 是否只扫描相机不扫描相册，不传则为false
   *   callback: function(success: boolean, result: object | string): void
   */
  scanCode: (param, callback) => engine.scanCode(param, callback)
};

import engine from "./engine/engine.js";
import engineData from "./engine/engineData.js";